package restlet;

import model.Prevoznik;
import model.Util;
import org.restlet.data.Reference;
import org.restlet.resource.ServerResource;

import restlet.interfaces.CarrierResourceI;
import beans.CarrierBean;

public class CarrierResource extends ServerResource implements CarrierResourceI{
	
	@Override
	public CarrierBean getCarrierByID() {
		
		String prevoznikId = Reference.decode((String) getRequest().getAttributes().get("carrierId"));
		if (prevoznikId == null) {
			return null;	
		}
		
		Prevoznik prevoznik = Util.getEntityFromTableByID(Prevoznik.class, prevoznikId);
		
		if (prevoznik == null) {
			return null;	
		}
		
		return prevoznik.toCarrierBean();
	}
}
